import {computed, effect, Injectable, signal} from '@angular/core';

@Injectable({
  providedIn: 'root'
})
export class AppStoreService {

  readonly age = signal(1)

  one = computed(() => this.age() - 10)
  two = computed(() => this.age() + 20)

  constructor() {
    effect(() => {
      console.log('>>>>>>age改变了：', this.age())
    })
  }

  updateAge() {
    this.age.update(value => value + 1)
  }
}
